<template>
  <a-card :bordered="false">
    <div style="display: flex; justify-content: space-between">
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <!-- <a-button @click="handleAdd" type="primary" icon="plus" v-has="'serverInfo:add'">新增</a-button> -->
        <!-- <a-button type="primary" icon="download" @click="handleExportXls('服务表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
        @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
        <a-dropdown v-if="selectedRowKeys.length > 0">
          <a-menu slot="overlay">
            <a-menu-item key="1" @click="batchDel"
              ><a-icon type="delete" v-has="'serverInfo:delete'" />删除</a-menu-item
            >
          </a-menu>
          <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
        </a-dropdown>
      </div>
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper" style="display: flex; justify-content: end">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24" v-has="'xhdjStatisticAnalysisMonth:select'">
              <a-form-item label="城市服务商" style="margin-right: 10px">
                <serveSelect @selectClick="selectClick" :value="queryParam.agencyCode"></serveSelect>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="开始时间">
                <a-month-picker v-model="queryParam.startTime" @change="startChange" />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="结束时间">
                <a-month-picker v-model="queryParam.endTime" @change="endChange" />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin: 0 8px">重置</a-button>
                <a-button type="primary" icon="download" @click="handleExportXls('服务表')">导出</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </div>
<!--    <div class='ant-alert ant-alert-info' style='margin-bottom: 15px'>-->
<!--      <span style='margin-right: 20px'-->
<!--      >平台收入=<span style='font-size: 16px; color: red'>(实际营业额+充值金额)-技师车费收入-技师服务收入-实际退款出账-返佣 </span-->
<!--      ></span-->
<!--      >-->
<!--    </div>-->
    <div class='ant-alert ant-alert-info' style='margin-bottom: 15px'>
      <span style='margin-right: 20px'
      >平台截流=<span style='font-size: 16px; color: red'>(实际营业额(已扣除退款)+充值金额)-已提现提现车费-已提现服务费-提现佣金 </span
      ></span
      >
    </div>
    <div class='ant-alert ant-alert-info' style='margin-bottom: 15px'>
      <span style='margin-right: 20px'>参数说明
      <span style='font-size: 16px; color: #f501fd'>
        总营业额:(微信支付项目+支付宝支付项目+充值余额支付项目) --- 实际营业额:(微信支付项目+支付宝支付项目)
      </span >
      </span>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="1"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
        autoHeight
      >
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <!-- <xhdjServerInfo-modal ref="modalForm" @ok="modalFormOk"></xhdjServerInfo-modal> -->
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getFileAccessHttpUrl, getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import serveSelect from '@/components/serveSelect.vue'

export default {
  name: 'xhdjStatisticAnalysisJlMonthList',
  mixins: [JeecgListMixin],
  components: {
    serveSelect
  },
  data () {
    return {
      description: '服务表管理页面',
      // 表头
      columns: [
        {
          title: '时间',
          align: 'center',
          dataIndex: 'time'
        },
        {
          title: '总营业额',
          align: 'center',
          dataIndex: 'xdTotalAmount'
        },
        {
          title: '实际营业额',
          align: 'center',
          dataIndex: 'xdAmount'
        },
        {
          title: '充值金额',
          align: 'center',
          dataIndex: 'topAmount'
        },
        {
          title: '总共退款金额',
          align: 'center',
          dataIndex: 'tkTotalAmount'
        },
        {
          title: '实际退款出账',
          align: 'center',
          dataIndex: 'tkAmount'
        },
        {
          title: '技师服务提现',
          align: 'center',
          dataIndex: 'jsfwTxAmount'
        },
        {
          title: '技师车费提现',
          align: 'center',
          dataIndex: 'jscfTxAmount'
        },
        {
          title: '佣金提现',
          align: 'center',
          dataIndex: 'fyTxAmount'
        },
        {
          title: '平台截流',
          align: 'center',
          dataIndex: 'ptJlAmount'
        }
      ],
      url: {
        list: '/finance/sysxhdjFundsLog/monthJlList',
        delete: '/xhdjServerInfo/delete',
        deleteBatch: '/deleteBatch',
        exportXlsUrl: '/finance/sysxhdjFundsLog/statisticsJlMonthExport',
        importExcelUrl: 'xhdjServerInfo/importExcel',
        init: '/finance/sysxhdjFundsLog/statisticsJlMonth'
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },

  methods: {
    getAvatarView: function (avatar) {
      return getFileAccessHttpUrl(avatar)
    },
    startChange (date, dateString) {
      this.queryParam.startTime = dateString + '-01'
    },
    endChange (date, dateString) {
      this.queryParam.endTime = dateString + '-01'
    },
    selectClick (value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    },
    init () {
      getAction(this.url.init, this.queryParam).then(res => {
        if (res.code == 200) {
          res.result.map(res => {
            res.time = '合计'
          })
          this.dataSource.push(...res.result)
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
